// -*- coding: utf-8 -*- 
/**
 * Project: Java8InActionT
 *
 * @author: yanking
 * Create time: 2022-03-18 20:56
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.DesignPattern;

public class Validator {
    private final StrategyPattern.ValidateStrategy strategy;

    public Validator(StrategyPattern.ValidateStrategy v) {
        strategy = v;
    }

    public boolean validate(String s) {
        return strategy.execute(s);
    }

    public static void main(String[] args) {
        Validator LowercaseValidator = new Validator(new StrategyPattern.IsAllLowerCaseStrategy());
        if (LowercaseValidator.validate("aaaa")) {
            System.out.println("Is Allowecase!");
        } else {
            System.out.println("Isn't Numerical");
        }
        Validator numericalValidator = new Validator(new StrategyPattern.IsNumberCaseStrategy());
        if (numericalValidator.validate("123456")) {
            System.out.println("Is Numerical!");
        } else {
            System.out.println("Isn't Numerical");
        }
    }

}
